﻿// Copyright (c) Microsoft Corporation.  All rights reserved. 
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace WiE.Utils
{
    class NetworkUtils
    {
        #region PInvokes to WinInet
        [DllImport("Wininet.dll")]
        private static extern bool InternetGetConnectedState(out int Description, int ReservedValue);

        [DllImport("Wininet.dll")]
        private static extern bool InternetCheckConnection(string Url, int Flags, int ReservedValue);
        #endregion

        public static bool IsInternetAccessible()
        {
            int lpdwFlags;

            bool bReturnValue = InternetGetConnectedState(out lpdwFlags, 0);

            return bReturnValue;
        }
    }
}
